class Hello { public static void main ( String[] args ) { System.out.println("Hello World!"); } }
Most classes contain many more lines than this one. Everything that makes up a class is placed between the first brace { and its matching last brace } .
The name of the class (and therefore the name of the file) is up to you. In programming, the name for something like a class is called an identifier. An identifier consists of alphabetical characters and digits. The first character must be alphabetical, the remaining characters can be mixed alphabetic characters and digits (plus the two characters '_' and '$' underscore and dollar sign). No spaces are allowed inside the name. Chapter nine discusses this in more detail.
Usually a class name starts with a capital letter,
but this is not required.
A source file should always end with .java
in lower case.
A reserved word is a word like class
that
has a special meaning to the system.
For example, class
means that a definition of
a class immediately follows.
You must use reserved words only for their intended purpose.
(For example, you can't use the word class
for any other purpose than defining a class.)
Which of the following look like good identifiers? (click on an identifier to verify your answer)